/*
 * ListDataEvent.java  0.4.0 / Oct 24, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
package com.cute4j.swing.events;

import java.util.EventObject;

/**
 * List Data Event.
 *
 * @author Slobodan Vrkacevic
 * @version 0.4.0
 */
public class ListDataEvent extends EventObject {

// Public Static Fields. -------------------------------------------------------

  /**
   * Contents change event.
   */
  public static final int CONTENTS_CHANGED = 0;

  /**
   * Interval added.
   */
  public static final int INTERVAL_ADDED = 1;

  /**
   * Interval removed.
   */
  public static final int INTERVAL_REMOVED = 2;

// Private Static Fields. ------------------------------------------------------

  private static final long serialVersionUID = 3017232919689405880L;

// Private Fields. -------------------------------------------------------------

  private final int type;
  private final int index0;
  private final int index1;

// Public Constructors. --------------------------------------------------------

  /**
   * Constructs new ListDataEvent object.
   *
   * @param source the source of the event
   * @param type the event type
   * @param index0 the lower index of the range
   * @param index1 the upper index of the range
   *
   * @throws IllegalArgumentException if the source is <tt>null</tt>
   */
  public ListDataEvent(Object source, int type, int index0, int index1) {
    super(source);
    this.type = type;
    this.index0 = index0;
    this.index1 = index1;
  }

// Public Methods. -------------------------------------------------------------

  /**
   * Returns event type.
   *
   * @return event type
   */
  public int getType() {
    return type;
  }

  /**
   * Returns the lower index of the range.
   *
   * @return the lower index of the range
   */
  public int getIndex0() {
    return index0;
  }

  /**
   * Returns the upper index of the range.
   *
   * @return the upper index of the range
   */
  public int getIndex1() {
    return index1;
  }

// Overridden Methods. ---------------------------------------------------------

  /**
   * {@inheritDoc}
   */
  public String toString() {
    return getClass().getName() + "[type=" + getType() + ",index0=" +
           getIndex0() + ",index1=" + getIndex1() + "]";
  }

}
